package com.aliyun.appdemo.controller;

import com.aliyun.appdemo.data.Result;
import com.aliyun.appdemo.pojo.Todo;
import com.aliyun.appdemo.service.TodoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TodoController
 *
 * @author solution
 * @date 2024/05/11
 */
@RestController
@RequestMapping("/")
public class TodoController {
    @Autowired
    private TodoService todoService;

    @GetMapping("/listTodo")
    public Result<List<Todo>> list() {
        return Result.success(todoService.selectList(null));
    }


    @PostMapping("/createTodo")
    public Result<Boolean> create(@RequestBody Todo todo) {
        return Result.success(todoService.insert(todo));
    }
}
